package thread;

import org.omg.CosNaming.NamingContextExtPackage.StringNameHelper;

public class ThreadInfoDemo {
    public static void main(String[] args) {
        //主线程执行main方法，因此在main方法中获取当前线程就是获取主线程
        Thread main = Thread.currentThread();
        System.out.println(main);
        doSome();//主线程会执行doSome方法
    }

    public static void doSome() {
        Thread t = Thread.currentThread();
        System.out.println("执行doSome方法的线程是:" + t);

        String name = t.getName();
        System.out.println("name:" + name);

        long id = t.getId();
        System.out.println("id:"+ id);

        int priority = t.getPriority();//优先级，默认为5
        System.out.println("优先级:" + priority);

        boolean isDaemon = t.isDaemon();
        boolean isInterrupted = t.isInterrupted();
        boolean isAlive = t.isAlive();
        System.out.println("是否为守护线程：" + isDaemon);
        System.out.println("是否被中断：" + isInterrupted);
        System.out.println("是否活着：" + isAlive);

    }

}